package com.gxc.controller;

import com.gxc.mq.Demo1_Provider;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.*;

/**
 * @author GongXincheng
 * @since 2019-08-23 00:43
 */
@RestController
public class RabbitMqController {

    @Resource private Demo1_Provider demo1_provider;

    @GetMapping("/send")
    public Boolean Boolean() {
        ExecutorService executor = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MINUTES,
                new LinkedBlockingQueue<>(), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());

        for (int i = 0; i < 10000; i++) {
            executor.execute(() -> demo1_provider.send());
        }
        executor.shutdown();
        return true;
    }

}
